#ifndef __PIXEL_BUTTON_H__
#define __PIXEL_BUTTON_H__

#include "jpeg/jpegdecoder.h"
#include "input/inputobj.h"
#include "../renderobj.h"

typedef void (Delegater::*OnButtonClickFunc)();

class PixelButton : public InputObj, public RenderObj
{
	enum ButtonStatus
	{
		ButtonStatus_Normal,
		ButtonStatus_Hover,
		ButtonStatus_Down
	};
public:
	PixelButton(string strName, Point pos, float z);
	~PixelButton();

	void SetEnable(bool e);

private:
	unsigned int LoadFile(string strPath);
	ImageData GetImageData(string strJpegPath);
	unsigned int GetDrawList(ImageData& data);
	void GetButtonSize(int biWidth, int biHeight);

	void OnRender(float differTime);
	void FireOnClickEvent();

	bool HitTest(Point curPos);
	void OnMouseMove(Point pos);
	void OnMouseLButtonDown(Point pos);
	void OnMouseLButtonUp(Point pos);

public:
	Event<OnButtonClickFunc> OnClick;

private:
	unsigned int m_texNormal;
	unsigned int m_texHover;
	unsigned int m_texDown;

	Size m_biSize;
	float m_width;
	float m_height;

	bool m_bDown;
	bool m_bEnable;

	Point m_pos;
	float m_z;

	ButtonStatus m_status;
};

#endif